package com.nlp.server.controller;

import com.nlp.common.core.web.pojo.AjaxResult;
import com.nlp.server.constant.BaiDuConstant;
import com.nlp.server.utils.BaiDuUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 百度相关接口
 * @author shiliuyinzhen
 */
@RestController
@RequestMapping("/baidu")
@Api(tags = "百度相关接口")
public class BaiDuController {

    @Autowired
    private BaiDuUtils baiDuUtils;

    /**
     * 将音频转换为文本
     * @return
     */
    @ApiOperation("将mp3音频转换为文本")
    @GetMapping("/voice")
    public AjaxResult getTextByVoice(@RequestParam("fileUrl") String fileUrl){
        String text = baiDuUtils.getTextByVoice(fileUrl, BaiDuConstant.FORMAT_MP3,
                BaiDuConstant.PID_CHINESE_NEAR_FIELD, BaiDuConstant.RATE_DEFAULT);
        return AjaxResult.success(text);
    }

}
